package com.treasure.service.common.controller;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.common.service.ImageService;
import com.treasure.service.enums.CodeEnum;
import com.treasure.service.result.ResponseResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/** 
* @ClassName    : InviteController 
* @author       : panxingwu 
* @date         : 2018年11月29日 下午10:57:34 
* @Description  : 获取邀请海报地址接口
*/
@Api(value = "邀请",description = "邀请相关操作")
@RestController
@RequestMapping("/image/v1")
@Slf4j
public class ImageController {
	@Autowired
	private ImageService imageService;
	
    @ApiOperation(value = "获取邀请海报", notes = "获取邀请海报")
    @LogInfo(log = "获取邀请海报",isPrint = true)
    @PostMapping("/getHaiBao")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型（1邀请会员  2邀请办卡）", required = true, dataType = "String", paramType = "query"),
    })
    public ResponseEntity<ResponseResult> getHaiBao(@RequestParam(value = "type") String type) throws UnsupportedEncodingException {
        log.info("获取推广海报参数：type="+type);
//    	String url = "http://pi9ss0u5h.bkt.clouddn.com/haibao_vip.png";
//        if("2".equals(type)) url="http://pi9ss0u5h.bkt.clouddn.com/haibao_card.png";
//        if("3".equals(type)) url="http://pi9ss0u5h.bkt.clouddn.com/becomevip_haibao.png";
//        log.info("获取推广海报结果：url="+url);
        String imgUrl = imageService.getHaiBao(type);
        return  ResponseEntity.ok(new ResponseResult(CodeEnum.SUCCESS,imgUrl));

    }
}
